package net.sppan.base.dao;

import net.sppan.base.dao.support.IBaseDao;
import net.sppan.base.entity.User;
import net.sppan.base.entity.mgEntity.MgUser;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.Map;

@Repository
public interface IMgUserDao extends IBaseDao<MgUser, Integer> {

	MgUser findByUserName(String username);

	long countAllByAppointmentTime(String appointmentTime);

	MgUser findByTelephone(String telephone);

	@Query(value="SELECT COUNT(1) AS num,m.teacher_Name AS appointmentType,m.appointment_Time AS appointmentTime FROM mg_user m WHERE m.appointment_Time !='' GROUP BY m.teacher_Name, m.appointment_Time;",nativeQuery = true)
	Object[] queryAppointtimeNum();

	Page<MgUser> findAllByUserNameContaining(String searchText, Pageable pageable);

}
